import 'package:bruno/bruno.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sph_driver/Main/EditInformation/EditCarCard.dart';
import 'package:sph_driver/Main/EditInformation/EditDriverCard.dart';

import '../../AppConfig/Config.dart';
import '../../AppConfig/RouteAct.dart';
import '../../http/NoLoadingGetApi.dart';
import '../../l10n/messages.dart';
import '../EditInformation/EditIDCard.dart';
import 'ModifyPhoneNumber.dart';

class ServiceDataModification extends StatefulWidget {
  const ServiceDataModification({super.key});

  @override
  State<ServiceDataModification> createState() => _ServiceDataModificationState();
}

class _ServiceDataModificationState extends State<ServiceDataModification> {
  Map userMap={};
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getUserInfo();
  }
  void getUserInfo(){
    NoLoadinggetApiManager.getData(
      context, // 上下文对象，用于显示提示信息等
      'api/auth/shipper/user/getLoginUser', // 您的API端点
      {}, // 查询参数，如果没有可以传递null
          (responseData)  {
        setState(() {
          userMap=responseData['data'];
        });
      },
    );
  }
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    var messages = AppLocalizations.of(context)!;
    return Scaffold(
      appBar: AppBar(
        backgroundColor:Color(0xFFFBECE4),
        centerTitle: true,
        title: Text("资料修改",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w300,fontSize: 16.sp),),
      ),
      body: Container(
        padding: EdgeInsets.only(left: 20.w,right:20.w,top: 8.h,),
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: [Color(0xFFFBECE4),MyColors.backgreyColor],
            begin: Alignment.topCenter,
            end: Alignment(0.0, -0.55),
          ),
        ),
        child: ListView(
          children: [
            Container(
              padding: EdgeInsets.only(top: 10.h,bottom: 10.h,),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(10)),
              ),
              child:  Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  BrnIconButton(
                      name: "手机号",
                      style: TextStyle(
                        fontSize: 13.sp,
                        color: Colors.black,
                      ),
                      direction: Direction.bottom,
                      padding: 4.h,
                      iconHeight: 30.h,
                      iconWidth: 30.w,
                      iconWidget: Image.asset("lib/Images/PersonCenter/修改资料手机号.png"),
                      onTap: () {
                        Navigator.push( context, FadeRoute(page:ModifyPhoneNumber(phoneNum: userMap['phoneNum'], userMap: userMap,)));
                      }),
                  BrnIconButton(
                      name: "身份证",
                      style: TextStyle(
                        fontSize: 13.sp,
                        color: Colors.black,
                      ),
                      direction: Direction.bottom,
                      padding: 4.h,
                      iconHeight: 30.h,
                      iconWidth: 30.w,
                      iconWidget: Image.asset("lib/Images/PersonCenter/修改资料身份证.png"),
                      onTap: () {
                        Navigator.push( context, FadeRoute(page:EditIDCard(dataMap: userMap,)));
                      }),
                  BrnIconButton(
                      name: "行驶证",
                      style: TextStyle(
                        fontSize: 13.sp,
                        color: Colors.black,
                      ),
                      direction: Direction.bottom,
                      padding: 4.h,
                      iconHeight: 30.h,
                      iconWidth: 30.w,
                      iconWidget: Image.asset("lib/Images/PersonCenter/修改资料行驶证.png"),
                      onTap: () {
                        Navigator.push( context, FadeRoute(page:EditDriverCard(dataMap: userMap,)));
                      }),
                  BrnIconButton(
                      name: "驾驶证",
                      style: TextStyle(
                        fontSize: 13.sp,
                        color: Colors.black,
                      ),
                      direction: Direction.bottom,
                      padding: 4.h,
                      iconHeight: 30.h,
                      iconWidth: 30.w,
                      iconWidget: Image.asset("lib/Images/PersonCenter/修改资料驾驶证.png"),
                      onTap: () {
                        Navigator.push( context, FadeRoute(page:EditCarCard(dataMap: userMap,)));
                      }),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
